package com.mms.utsc.smartnet;

import java.util.ArrayList;

import android.app.Activity;
import android.app.ListActivity;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;

public class MainMenu extends Activity implements OnItemClickListener {

	private ArrayList<MenuListItem> menuList = new ArrayList<MenuListItem>();
	private ListView listView;

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);


		// initialize the menu items
		/*
		 * menuList.add(new MainMenuItem(R.drawable.courses, "Courses", new
		 * Intent(MainMenu.this, CoursesMenu.class)));
		 */
		menuList.add(new MainMenuItem(R.drawable.announcements, "Announcements", new Intent(MainMenu.this, AnnouncementsViewPager.class)));
		menuList.add(new MainMenuItem(R.drawable.timetable, "Timetables", new Intent(MainMenu.this, AddCourseActivity.class)));
		/*
		 * menuList.add(new MainMenuItem(R.drawable.announcements,
		 * "Announcements", new Intent(MainMenu.this,
		 * AnnouncementsActivity.class)));
		 */
		menuList.add(new MainMenuItem(R.drawable.settings, "Preferences", new Intent(MainMenu.this, FragmentPreferences.class)));
		menuList.add(new MainMenuItem(R.drawable.about, "About", new Intent(MainMenu.this, About.class)));
		/*
		 * menuList.add(new MainMenuItem(R.drawable.btn_logout, "Logout", new
		 * Intent(MainMenu.this, LogoutActivity.class)));
		 */

		setContentView(R.layout.main_menu);
		listView = (ListView) findViewById(R.id.lvMainMenu);
		// instead of setContentView
		listView.setAdapter(new ListViewImageTextAdapter(MainMenu.this, menuList, R.layout.main_menu_item));
		listView.setOnItemClickListener(this);
	}

	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
		/** Testing code **/
		SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
		boolean enable_notify = prefs.getBoolean("enable_notifications", false);
		Toast.makeText(MainMenu.this, "Value of enable_notifications is: " + enable_notify, Toast.LENGTH_LONG).show();
		/** Testing code **/
	}

	public void onItemClick(AdapterView<?> arg0, View v, int position, long id) {
		// String classToLaunchStr = classMap[position][1];
		startActivity(menuList.get(position).getIntentToLaunch(MainMenu.this));
	}
}